package com.example.drawproject.ItemClass;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

import com.example.drawproject.R;

public class People {
    private int life = 100;
    private int damage = 5;
    private int defence = 5;
    private Integer[] walk = {R.drawable.walk1, R.drawable.walk2, R.drawable.walk3, R.drawable.walk4, R.drawable.walk5, R.drawable.walk6};
    private Integer[] run = {R.drawable.run1, R.drawable.run2, R.drawable.run3, R.drawable.run4, R.drawable.run5, R.drawable.run6};
    private Bitmap[] bitmapsRun;
    private Bitmap[] bitmapsWalk;
    //    private Canvas canvas;
    private int status = 1;
    //0为不动 1为走 2为跑
    private int Index = 0;
    private Context context;

    public People(Context context) {
        this.context = context;
        initData();
    }

    private void initData() {
        bitmapsRun = new Bitmap[6];
        bitmapsWalk = new Bitmap[6];
        for (int i = 0; i <= 5; i++) {
            bitmapsRun[i] = BitmapFactory.decodeResource(context.getResources(), run[i]);
            bitmapsWalk[i] = BitmapFactory.decodeResource(context.getResources(), walk[i]);
        }
    }

    public void setStatus(int status) {
        if (this.status != status) {
            this.status = status;

            Index = 0;
        }
    }

    public Bitmap getMove() {
        if (Index == 6) {
            Index = 0;
        }
        if (status == 1) {
            return bitmapsWalk[Index++];
        } else {
            return bitmapsRun[Index++];
        }
    }

    //
    public void setCoordinate(float x, float y) {
//
//    }

    }
}
